package com.nine.demo.filemanager.controller;

import com.nine.demo.filemanager.file.AliyunOssClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description:
 * @Author: 刘超
 * @Date: 2023-03-24 16:57
 */
@RestController
@RequestMapping("/oss")
public class OssServiceController {

    @Autowired
    AliyunOssClient aliyunOssClient;

    @GetMapping("/upload")
    public String uploadFile(@RequestParam(name = "content", required = false) String content) {
        if (aliyunOssClient.saveFile("test.txt", content)) {
            return "success";
        } else {
            return "fail";
        }
    }

    @GetMapping("/load")
    public String getContent(){
        byte[] content = aliyunOssClient.getContent("test.txt");
        return new String(content);
    }


}
